from elasticsearch import Elasticsearch
# es = Elasticsearch()    # 默认连接本地elasticsearch
es = Elasticsearch(['119.91.216.229:9200'])  # 连接本地9200端口
print(es.index(index='py2', doc_type='doc', id=1, body={'name': "张开", "age": 18}))

print(es.get(index='py2', doc_type='doc', id=1))
# es = Elasticsearch(
#     ["192.168.1.10", "192.168.1.11", "192.168.1.12"], # 连接集群，以列表的形式存放各节点的IP地址
#     sniff_on_start=True,    # 连接前测试
#     sniff_on_connection_fail=True,  # 节点无响应时刷新节点
#     sniff_timeout=60    # 设置超时时间
# )
